package in.muton.edushare.pages.deptpages;

import in.muton.edushare.pages.common.PollsStatsPanel;
import in.muton.edushare.poll.panels.PollList;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.basic.Label;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.dao.PollStatsDAO;

public class DeptPolls extends DeptBase {

	public DeptPolls(PageParameters params) {
		super(params);
		add(CSSPackageResource
				.getHeaderContribution(PollList.class, "Poll.css"));
		add(new Label("heading","Polls and Feedback"));

		PollStatsDAO ps = new PollStatsDAO(getSessionORMInterface());
		add(new PollsStatsPanel("statsFrag", ps.getTotalPolls(getModel()
			.getObject()), ps.getOpenPolls(getModel().getObject()), ps
			.getClosedPolls(getModel().getObject()), ps
			.getDraftPolls(getModel().getObject())));
		add(new PollList("activePanel", getModel().getObject(), this));
	}

	@Override
	protected String getActivePage(PageParameters params) {
		return "DeptPoll";
	}

	@Override
	public String getPageTitle() {
		return getLoggedInUser().getCompleteUserName() + " | "
				+ getModel().getObject().getDeptName() + " | Polls | "
				+ ApplicationConstants.APPLICATION_NAME;
	}
}
